Skip to content

Security: Add SSRF and local resource access protection#31

Open
Jah-yee wants to merge 3 commits intogarrytan:mainfrom
Jah-yee:fix/browse-default-sonnet
Open

Security: Add SSRF and local resource access protection#31
Jah-yee wants to merge 3 commits intogarrytan:mainfrom
Jah-yee:fix/browse-default-sonnet

Conversation

@Jah-yee
Copy link

@Jah-yee Jah-yee commented Mar 13, 2026

Summary

This PR adds URL validation to prevent Server-Side Request Forgery (SSRF) and local resource access attacks in the browse command.

Changes

  • Added url-validator.ts with a validateUrl() function that:

    • Blocks file:// URLs by default (opt-in with --allow-file)
    • Blocks localhost/loopback addresses (localhost, 127.0.0.1, ::1)
    • Blocks RFC1918 private IP ranges (opt-in with --allow-private)
    • Blocks cloud metadata endpoints (169.254.169.254)
    • Blocks .internal and .localhost hostnames
  • Applied validation to:

    • goto command in write-commands.ts
    • newTab() method in browser-manager.ts
    • diff command in meta-commands.ts

Fixes

Fixes #17

AI Assistant and others added 3 commits March 13, 2026 03:21
- Add validateOutputPath() to restrict output paths to /tmp or CWD
- Add validateFilePath() to prevent arbitrary file read via eval
- Resolves issue garrytan#13 (path traversal allows arbitrary file read/write)
The browse skill had no model specified in the frontmatter, causing it to
use the user's default model (usually Opus) by default. Since browse is
orchestrating CLI commands with minimal reasoning required, Sonnet is more
cost-effective while maintaining good performance.

This addresses issue garrytan#8.
- Add url-validator.ts with validateUrl() function
- Blockfile:// URLs by default (opt-in with --allow-file)
- Block localhost, 127.0.0.1, ::1
- Block RFC1918 private IP ranges (opt-in with --allow-private)
- Block cloud metadata endpoints (169.254.x.x)
- Block .internal and .localhost hostnames
- Apply validation to goto, newTab, and diff commands

Fixes: garrytan#17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Security] SSRF and local resource access via unrestricted URL handling

2 participants